m = int(input())
n = int(input())
num = 1
index = 1
while num <= n:
    if num % 7 != 0:
        index = index % m + 1
    num += 1
print(index)